package com.qingyun.cameralab

import android.graphics.Color
import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.qingyun.cameralab.databinding.ActivityPiechatBinding
import com.qingyun.cameralab.views.PieChartData

class PieChatActivity : AppCompatActivity() {
    private lateinit var viewBinding: ActivityPiechatBinding
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        viewBinding = ActivityPiechatBinding.inflate(layoutInflater)
        enableEdgeToEdge()
        setContentView(viewBinding.root)
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }

        // 在Activity/Fragment中
        val data = listOf(
            PieChartData(30f, Color.RED, "Red Red"),
            PieChartData(50f, Color.BLUE, "Blue Blue"),
            PieChartData(20f, Color.GREEN, "Green Green")
        )
        viewBinding.pieChartView.setData(data)
    }
}